import java.util.concurrent.Callable;

class Shape
{
    public void draw()
    {
        System.out.println("画图形");
    }
}

class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("画矩形");
    }
}
class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("画圆");
    }
}

class Flower extends Shape{
    @Override
    public void draw() {
        System.out.println("画花");
    }
}
public class Test2 {


    public static void drawShapes() {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();
        String[] shapes = {"cycle", "rect", "cycle", "rect", "flower"};
        for (String shape : shapes) {
            if (shape.equals("cycle")) {
                cycle.draw();
            } else if (shape.equals("rect")) {
                rect.draw();
            } else if (shape.equals("flower")) {
                flower.draw();
            }
        }
    }

    public static void drawShapes1() {
        Shape rect = new Rect();
        Shape cycle = new Cycle();
        Shape flower = new Flower();
        Shape[] shapes = {cycle,rect,cycle,rect,flower};
        for (Shape shape:shapes) {
            shape.draw();
        }

    }


    public static void drawShapes2() {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();
        Shape[] shapes = {cycle,rect,cycle,rect,flower};
        for (Shape shape:shapes) {
            shape.draw();
        }

    }
    public static void func(Shape shape)
    {
        //向上转型
        shape.draw();
    }

    public static void main(String[] args) {
//        Rect rect=new Rect();
//        Cycle cycle=new Cycle();
        func(new Rect());
        func(new Cycle());
        func(new Flower());
//        Shape shape=new Rect();
//        Shape shape1=new Cycle();
//        Shape shape2=new Flower();

    }
    public static void main2(String[] args) {
        drawShapes();
        System.out.println("=========");
        drawShapes1();
        System.out.println("===========");
        drawShapes2();
    }
    public static void main1(String[] args) {
        Rect rect=new Rect();
       Cycle cycle=new Cycle();
       func(rect);
       func(cycle);
       func(new Flower());
    }
}
